package com.wjjun.base.ui.base;

import android.databinding.ObservableField;

import com.wjjun.viewmodel.TabItemViewModel;
import com.wjjun.viewmodel.TabViewPagerViewModel;

/**
 * tabActivity
 * Created by 67535 on 2018/5/10.
 */
public class TabViewModel extends BaseActivityViewModel {

    public final ObservableField<TabViewPagerViewModel> tabViewPagerViewModel = new ObservableField<>(new TabViewPagerViewModel());

    @SuppressWarnings("ConstantConditions")
    public void clearTabs(){
        tabViewPagerViewModel.get().tabs.clear();
    }

    @SuppressWarnings("ConstantConditions")
    public void addTab(TabItemViewModel tab) {
        if (tabViewPagerViewModel.get() == null) {
            tabViewPagerViewModel.set(new TabViewPagerViewModel());
        }
        tabViewPagerViewModel.get().tabs.add(tab);
    }

    @SuppressWarnings("ConstantConditions")
    public TabItemViewModel getTabItem(int index) {
        return tabViewPagerViewModel.get().tabs.get(index);
    }
}
